/**
 * 
 */
package com.ms.game.itembox.container;

import com.ms.game.itembox.Item;
import com.ms.game.itembox.message.SBroadcastMessage;
import com.ms.player.Player;
import com.ms.service.module.zone.module.BasicZoneModule;
import com.xpec.c4.game.utility.GUID;
import com.xpec.c4.game.utility.wordfilter.WordFilters;
import com.xpec.c4.message.MessageTypes;
import com.xpec.c4.service.group.transportlayer.BroadcastTargetTypes;
import com.xpec.c4.service.message.MessageAction;

/**
 * 全頻卡
 * 
 * @author TW15010
 */
public class ItemChannelBroadcastCard extends ItemBasic {

	// ServerCore only ======================================================

	@Override
	public int use(Player player, Item useItem, int useCount, GUID targetGuid, Object... object) {
		return 0;
	}

	/**
	 * 傳送使用全頻卡的結果給 client
	 * 
	 * @param sessionId
	 *            client session id
	 * @param resultCode
	 *            錯誤碼
	 */
	public static void sendUseBroadcastCardResponse(GUID sessionId, int resultCode) {
		MessageAction.sendMessage(sessionId, MessageTypes.S_ZONE_USE_BROADCAST_CARD_RESPONSE, resultCode);
	}

	/**
	 * 通知 client 顯示全頻廣播訊息內容
	 * 
	 * @param senderName
	 *            傳送者名字
	 * @param message
	 *            訊息內容
	 */
	public void sendBroadcastMessage(String senderName, String message) {
		if (senderName == null || message == null) {
			return;
		}

		// 髒字過濾
		String cleanMessage = WordFilters.filterChatKeyword(message);

		SBroadcastMessage data = new SBroadcastMessage();
		data.setSenderName(senderName);
		data.setMessage(cleanMessage);

		MessageAction.broadCastMessage(MessageTypes.S_ZONE_BROADCAST_MESSAGE, data,
				BroadcastTargetTypes.BROADCAST_TO_ALL);
	}

	@Override
	public int applyItemToDc(BasicZoneModule zoneModule, Player player, Item useItem, GUID orderId, Object... object) {
		return 0;
	}


}
